yugiohdecksfandomcom_es-20200216-history
Módulo:RecetaDeck2
local p = {} local html = {} function p.decks(frame) local sortcardnames = {} local cardnames = {} local decks = {} decks1 = {} decks2 = {} decks3 = {} local text = '' for name, value in pairs(frame.args) do if value ~= '' then local cardname = p.normalize(value) local index = '' .. tonumber(string.sub(name, 1)) local letter = string.sub(string.upper(name), 0, 1) if letter 'D' then decks1index = {cardname, value} else if letter 'E' then decks2index = {cardname, value} else if letter 'S' then decks3index = {cardname, value} end end end if cardnamescardname nil then cardnamescardname = {} table.insert(sortcardnames, cardname) end end end table.sort(sortcardnames) cardnames = p.getCardsData(sortcardnames) text = html.deck(decks, cardnames) return text end function p.getCardsData(sortcardnames) local temp = {} local RdDatos = {} local RdRestriccion = require('Módulo:RestriccionCarta') local RdLetter = '' for i, n in ipairs(sortcardnames) do local Letter = p.selectLetter(string.sub(n, 0, 1)) if RdLetter ~= Letter then RdLetter = Letter RdDatos = require('Módulo:RdDatos' .. RdLetter) end tempn = {} if RdDatosn ~= nil then local rddatos = RdDatosn tempn'nombre' = rddatos1 tempn'ingles' = rddatos2 tempn'carta' = rddatos3 tempn'atributo' = rddatos4 tempn'tipo' = rddatos5 if rddatos4 ~= 'mágica' and rddatos4 ~= 'trampa' then tempn'nivel' = rddatos6 tempn'ataque' = rddatos7 tempn'defensa' = rddatos8 end -- Los índices de restricción solo están en español (rddatos1) local restriccion = RdRestriccion[p.normalize(rddatos1)] if restriccion ~= nil then local str_restriccion = {'ocg', 'prohibida', 'limitada', 'semilimitada'} tempn'restriccion' = str_restriccionrestriccion end end end return temp end function p.selectLetter(letter) local a = { 'A' = 'A', 'B' = 'B', 'C' = 'C', 'D' = 'D', 'E' = 'E', 'F' = 'F', 'G' = 'G', 'H' = 'H', 'I' = 'I', 'J' = 'J', 'K' = 'K', 'L' = 'L', 'M' = 'M', 'N' = 'N', 'O' = 'O', 'P' = 'P', 'Q' = 'Q', 'R' = 'R', 'S' = 'S', 'T' = 'T', 'U' = 'U', 'V' = 'V', 'W' = 'W', 'X' = 'X', 'Y' = 'Y', 'Z' = 'Z' } letter = aletter or '7' return letter end function p.normalize (cardname) cardname = string.lower(cardname) cardname = string.gsub(cardname, 'á', 'a') cardname = string.gsub(cardname, 'ä', 'a') cardname = string.gsub(cardname, 'é', 'e') cardname = string.gsub(cardname, 'ë', 'e') cardname = string.gsub(cardname, 'í', 'i') cardname = string.gsub(cardname, 'ï', 'i') cardname = string.gsub(cardname, 'ó', 'o') cardname = string.gsub(cardname, 'ö', 'o') cardname = string.gsub(cardname, 'ú', 'u') cardname = string.gsub(cardname, 'ü', 'u') cardname = string.upper(cardname) cardname = string.gsub(cardname, ' ', ) cardname = string.gsub(cardname, '"', '') cardname = string.gsub(cardname, "'", '') cardname = string.gsub(cardname, ',', '') cardname = string.gsub(cardname, '%.', '') cardname = string.gsub(cardname, '%-', '') cardname = string.gsub(cardname, '¡', '') cardname = string.gsub(cardname, '!', '') cardname = string.gsub(cardname, '¿', '') cardname = string.gsub(cardname, '%?', '') cardname = string.gsub(cardname, ':', '') cardname = string.gsub(cardname, 'º', '') cardname = string.gsub(cardname, '/', '') cardname = string.gsub(cardname, '#', '') cardname = string.gsub(cardname, '&', 'Y') cardname = string.gsub(cardname, 'ñ', 'Ñ') cardname = string.gsub(cardname, '☆', '') return cardname end function p.convnombreimagen(filename) filename = string.lower(filename) filename = string.gsub(filename, '/', '-') filename = string.gsub(filename, ', ) filename = string.gsub(filename, '\, ) filename = string.gsub(filename, '"', '') filename = string.gsub(filename, '"', '') filename = string.gsub(filename, '"', '') filename = string.gsub(filename, '?', '') filename = string.gsub(filename, 'f;', '') return filename end function html.deck (decks, cardnames) local text = '' -- Tab: Vista Principal text = text .. 'Vista Principal =\n' local vp = { 'titulo' = {'DECK PRINCIPAL', 'DECK EXTRA', 'SIDE DECK'}, 'letra' = {'D', 'E', 'S'}, 'bgcolor' = {'#e98b14', '#0099d2', '#8DB71B'}, 'gdcolor1' = {'#de6f03', '#0292c7', '#72aa01'}, 'gdcolor2' = {'#e98911', '#0099d2', '#92b920'}, 'gdcolor3' = {'#eab97f', '#74c3e2', '#b8cf75'} } local vp_strf = [[ '%s''' ]] -- (i) 1 Deck Principal, 2 Deck Extra, 3 Side Deck for i = 1, 3 do text = text .. string.format(vp_strf, vp.tituloi, vp.bgcolori, vp.gdcolor1i, vp.gdcolor2i, vp.gdcolor3i) if decksi.. 1 ~= nil then local j = 1 while decksi.. j ~= nil do local card = { 'id'= decksi.. j1, 'notfound' = decksi.. j2 } local cardname = cardnamescard.id text = text .. ' ' text = text .. html.cardview(cardname, card.notfound) text = text .. ' ' .. vp.letrai .. j .. ' ' j = j + 1 end else text = text .. ' -- Sin cartas -- \n' end text = text .. ' ' end text = text .. ' \n\n' text = text .. ' 32px Desarrollado con LUA ' -- Tab: 1-15 text = text .. '|-|\n' text = text .. '1-15=\n' text = text .. ' \n' return text end function html.cardview (cardname, notfound) local text = '' if cardname.carta ~= nil then local tmb_image = 'Thumb3 ' .. string.lower(cardname.carta) .. ' ' if cardname.atributo 'mágica' or cardname.atributo 'trampa' then tmb_image = tmb_image .. cardname.tipo else tmb_image = tmb_image .. cardname.atributo end local tmb_class = 'tmbfoto' local tmb_size = '40x40' if cardname.carta 'monstruo péndulo' or cardname.carta 'monstruo péndulo normal' then tmb_class = tmb_class .. 'pendulum' tmb_size = '48x36' end local tmb_filename = p.convnombreimagen(cardname.nombre) text = text .. ' image:' .. tmb_image .. '.png ' .. tmb_size .. 'px ' -- Restriccion if cardname.restriccion ~= nil then local restfilename = '' if cardname.restriccion 'ocg' then restfilename = 'icono ocg' else restfilename = 'Nuevo icono restricción ' .. cardname.restriccion end text = text .. ' Archivo:' .. restfilename .. '.png ' end else text = text .. ' ' .. notfound .. 'Categoría:Thumb desconocido ' end return text end function html.cardlist (cardname, notfound) local text = '' if cardname.nombre ~= nil then local tmb_filename = p.convnombreimagen(cardname.nombre) text = text .. '|class="tmb_list"|40px\n' text = text .. '|' .. cardname.nombre .. '' text = text .. ' ● ' .. cardname.ingles .. ' \n' text = text .. ' image:icono ' .. string.lower(cardname.carta) .. '.gif\n' text = text .. ' ● image:icono ' .. string.lower(cardname.atributo) .. '.gif' text = text .. ' ● image:icono ' .. string.lower(cardname.tipo) .. '.gif' if cardname.atributo ~= 'mágica' and cardname.atributo ~= 'trampa' then if cardname.carta 'monstruo xyz' then text = text .. ' ● image:icono rango.gif ' .. cardname.nivel else text = text .. ' ● image:icono nivel.gif ' .. cardname.nivel end text = text .. ' ● ' text = text .. 'image:icono ataque.gif ' .. cardname.ataque text = text .. ' ● image:icono defensa.gif ' .. cardname.defensa end if cardname.restriccion ~= nil then local restfilename = '' if cardname.restriccion 'ocg' then restfilename = 'icono ocg' else restfilename = 'Nuevo icono restricción ' .. cardname.restriccion end text = text .. ' ● image: ' .. restfilename .. '.png ' end text = text .. ' \n' else text = text .. '|colspan=2 height=43px style="text-align:center;"|\'\'Carta mal ingresada o no registrada (' .. notfound .. ').\'\'\n' end return text end return p